package team.star.werespos.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import team.star.werespos.model.enums.TimeRangeEnum;
import team.star.werespos.model.vo.ResultVO;
import team.star.werespos.service.OrderService;
import team.star.werespos.util.Result;

import java.util.Date;

/**
 * 销售统计模块
 * @author huangdonghong/huangdonghong@huya.com
 * @since 2019/05/21 17:31
 */
@RequestMapping("/admin/statistics")
@RestController
public class StatisticsController {

    @Autowired
    private OrderService orderService;

    /**
     * 日：近10天
     * 周：近10周
     * 月：今年12月
     * 季：今年四季
     * @param timeRange
     * @return
     */
    @GetMapping("")
    public ResultVO<?> getTurnover(@RequestParam(name = "timeRange", required = false, defaultValue = "1") Integer timeRange,
                                   @RequestParam(name = "year", required = false, defaultValue = "2019") Integer year) {
        return Result.success(
                orderService.listByTimeRange(year, TimeRangeEnum.getByRange(timeRange))
        );
    }
}
